/*
 * Copyright 2004 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jbfilter.test.beans;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.jbfilter.test.beans.util.ToStringUtils;

/**
 * A physical support for one ore more recordings.
 * @author Marcus Adrian
 *
 */
public abstract class RecordingSupport implements Cloneable {
	private Long id;
	private List<Recording> recordings = new ArrayList<Recording>();
	private Float price;
	
	protected RecordingSupport cloneProperties(RecordingSupport clone) {
		clone.setId(id);
		clone.setPrice(price);
		for (Recording recording : recordings) {
			clone.addRecording(recording.clone());
		}
		return clone;
	}
	@Override
	public String toString() {
		ToStringBuilder builder = ToStringUtils.getToStringBuilderMultipleLines(this);
		builder.append("id", id);
	    builder.append("price", price);
		for (Recording recording : recordings) {
			StringBuilder sb = new StringBuilder();
			sb.append(recording.getWork().getTitle());
			sb.append(" - ");
			sb.append(recording.getRecordingLocation());
			sb.append(" - ");
			sb.append(recording.getMonth()).append("/").append(recording.getYear());
			builder.append("recording", sb.toString());
		}
	    return builder.toString();
	}
	
	public boolean addRecording(Recording recording) {
		return recordings.add(recording);
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public List<Recording> getRecordings() {
		return recordings;
	}
	public void setRecordings(List<Recording> recordings) {
		this.recordings = recordings;
	}
	public Float getPrice() {
		return price;
	}
	public void setPrice(Float price) {
		this.price = price;
	}

	
}
